package com.zygh.lz.controller;

import com.alibaba.fastjson.JSONObject;
import com.zygh.lz.entity.Staff;
import com.zygh.lz.service.AccountService;
import com.zygh.lz.service.StaffService;
import com.zygh.lz.stapprove.SysPcLog;
import com.zygh.lz.vo.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@Api(tags = "pc端登录", description = "LoginController")
@RestController
public class LoginController {
    @Resource
    private StaffService staffService;
    @Resource
    private AccountService accountService;
//    @ApiOperation("登录")
//    @PostMapping("staffLogin")
//    public ResultBean staffLogin(String staff_tel, String staff_password) {
//        return staffService.selectByLogin(staff_tel, staff_password);
//    }
    @ApiOperation("登录")
    @PostMapping("staffLogin")
    public ResultBean staffLogin(String staff_tel,String staff_password){
        return accountService.selectByLogin(staff_tel, staff_password);
    }
    @ApiOperation("注册")
    @PostMapping("register")
    public ResultBean register(Staff staff) {
        return staffService.register(staff);
    }

    @ApiOperation("校验")
    @PostMapping("usercheck")
    public ResultBean usercheck(String name) {
        return staffService.usercheck(name);
    }


    @ApiOperation("删除人员信息")
    //@PostMapping("deletUserById")
    @SysPcLog(module = "删除人员信息",operation = "删除")
    public ResultBean deletUserById(@RequestBody String id) {
        String str = JSONObject.parseObject(id).get("id").toString();
        Integer new_id = Integer.parseInt(str);
        return staffService.delStaffInfoById(new_id);
    }


}
